home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / qbware.exe / QBFORMAT.BAS (.txt) < prev    next >
QuickBASIC Tokenized Source  |  1990-11-30  |  11KB  |  162 lines

  1. NMALLOCn
  2. Text+
  3. BsDFmt
  4. A0570
  5. A0570.Put.DiskMsg
  6. MaxTrackq
  7. Sectors
  8. SectSize`
  9. SECTSIXE
  10. Indicate    
  11. Bytes=
  12. Sector1
  13. OFFSETx
  14. SEGMENT
  15. OLD.MAXSECT
  16. MAXSECT#
  17. Buffer
  18. BsdWrit
  19. Usage
  20. Drive
  21. Track
  22. Write
  23. Write.Buffer
  24. Bytes.Sector
  25. Sectors.Cluster
  26. Reserved
  27. Reserved.Sectors
  28.     FAT.Count
  29. Dir.Entries
  30. Total
  31. Total.Sectors
  32. Media
  33. Media.Desc
  34. Sectors.Track
  35. Head.Count
  36. Hidden
  37. Hidden.Sectors
  38. Sectors.FAT
  39. diskette
  40. place
  41. illegal
  42. command
  43. Error
  44. Error.Routine
  45. Update
  46. Update.FAT
  47. BsdRead
  48. Copyright (c) 1988 Marcel Madonnae
  49. QBFORMAT.BAS will format a DS/DD diskette on a 360KB or a 1.2M diskette drive*
  50.   Note that no error checking is done.  This means that bad sectors will not
  51.   be flagged in the FAT. *
  52.   The diskette will be usable in every other respect.  The bootstrap routine
  53.   used on the Boot sector is fairly standard.  You can place yourr
  54.   own bootstrap routine on the diskette, but be aware that each version of
  55.   DOS may have a unique bootstrap routine and different manufacturers will
  56.   have different routines (i.e. COMPAQ DOS bootstrap routines may differ
  57.   from the bootstrap routine supplied by MS-DOS and PC-DOS).
  58.   You can improve on this routine by reading each cluster after it isr
  59.   formatted and marking the FAT if the cluster is bad.  You can also
  60.   accept parameters from the DOS prompt and format 1.2M diskettes or
  61.   create your own format.  CAUTION - MODIFYING THIS ROUTINE REQIURES
  62.   SOME KNOWLEDGE OF THE DISK BASE TABLE AND THE BIOS PARAMETER BLOCK.
  63.   UNINFORMED MODIFICATIONS CAN RESULT IN UNPREDICTABLE RESULTS
  64. * N O T E 
  65. This program cannot be used from the DOS prompt without Microsofti
  66. QuickBasic V4.0 and a registered copy of QBWARE.
  67. To compile it, at the DOS prompt type:
  68.  bc qbformat;s
  69.  link /ex /noe qbformat,,,brun40 qbware;
  70.  del qbformat.objf
  71.  del qbformat.mapf
  72. To run it from the QuickBasic development environment, type:
  73.  qb qbformat /l qbware
  74.  [Shift] + F5b
  75. To execute just type "QBFORMAT" at the DOS promptt
  76. For Example:
  77.  QBFORMATj
  78. will format a diskette in drive A:
  79. Qbformat - Version 1.0  (C) Copyright 1988 AJM Software"
  80. Use the A drive
  81. We will now format the diskette in Drive A: as a 9-Sector DS/DD diskette
  82. Do you wish to continue (Y/N)?
  83. Format aborted
  84.  Make sure that the Disk Base table is properly initialized
  85.  Default to 360k DS/DD diskr
  86.  The following code should be needed only for AT type machines
  87. Offset of DBT
  88. Segment of DBT
  89. The Disk Base Table is in ROM and cannot be altered"
  90. Indicate 9 sectors/track
  91. Initialize buffer area
  92. Indicate 40 tracks (0-39)
  93. Indicate 9 sectors/track
  94. Indicate 512 bytes/sector
  95. Initialize return code
  96. ...Formatting  CYL "
  97.   TRACK 
  98.  You can use the following code to check for bad clusters.  It's slow, but
  99.  it does workt
  100. FOR Sector% = 1 TO Sectors%t
  101.  CALL BsdRead(Buffer$, Drive$, Head%, Track%, Sector%, Rc%)e
  102.  IF Rc% <> 0 THENf
  103.  GOSUB Update.FATf
  104.  END IFU
  105. NEXT Sector%
  106.   Now setup the root directory. On a DS/DD diskette, the directory resides
  107.   on sectors 6 thru 12.  Note that sectors 10-12 are really sectors 1-3*
  108.   on track 0, head 1.2
  109. ...Initializing directory space"
  110.   Now let's write a fresh FAT.  Since 2 FAT's are the DOS standard, we'll
  111.   write two FAT's.  They reside on sectors 2-5 of track 0, head 0.
  112. ...Creating FAT"
  113.   The last thing we need is the boot record. 
  114.   First, set up the BIOS parameter block for DS/DD disk
  115. ...Initializing the BOOT Sector"
  116. AJM 1988
  117. Signature 
  118. Move the BPB to the Buffer
  119.  If you want to place a bootstrap routine on the BOOT sector, initialize
  120.  Buffer$ with the appropriate values here.  All of this stuff below is
  121.  a machine language bootstrap routine.
  122. IBMBIO  COM"
  123. IBMDOS  COM"
  124. Non-System disk or disk error$
  125. Replace and strike any key when ready"
  126. Disk boot failure$
  127. (c) AJM Software 1988"
  128. Restore the old value
  129. ...All done"
  130. Remember that this program is intended to be used as a demo"
  131. only.  No error checking was done so any bad clusters will
  132. not be marked as bad in the FAT.  This diskette is usable"
  133. in all other respects.
  134.  1   - illegal command
  135.  2   - sector not foundm
  136.  3   - write protect error
  137.  4   - bad sector
  138.  6   - disk drive door opened (some 1.2M drives only)
  139.  8   - DMA failure
  140.  9   - DMA overrun
  141.  16  - bad CRC:parity check
  142.  32  - controller malfunction
  143.  64  - seek failurea
  144.  128 - time outl
  145. Illegal command issued
  146. Sector not found
  147. Write protect error"
  148. Bad sector found
  149. Don't open the drive door during a format"
  150. DMA failure"
  151. DMA overrun"
  152. Bad CRC"
  153. Controller malfunction
  154. Seek failure
  155. Time-out
  156. Make sure the drive door is closed
  157. Error 
  158. Format halted 
  159.  You can update the FAT here if you want to make your diskette usable
  160.   when it contains bad clusters.
  161. Bad cluster found - do not use this diskette
  162.